package com.winqai.security.app.social;

import com.winqai.security.core.social.WinqaiSpringSocialConfigurer;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * 所有的类初始化都会经过接口BeanPostProcessor 实现的两个方法
 */
@Component
public class SpringSocialConfigurerPostProcessor implements BeanPostProcessor{

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if(StringUtils.equals(beanName, "winqaiSpringSocialConfigurer")){
            WinqaiSpringSocialConfigurer configurer = (WinqaiSpringSocialConfigurer)bean;
            configurer.signupUrl("/social/signUp");
            return configurer;
        }
        return bean;
    }
}
